﻿// -----------------------------------------------------------------------
// <copyright file="CookieConfig.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace NetFramework.Web.Configuration
{
    using System;
    using System.Xml.Serialization;
    using System.Collections.Generic;

    using NetFramework.Configuration;

    [ConfigFile("Configs/Cookie.config")]
    [XmlRoot("cookieConfig")]
    public class CookieConfig
    {
        private ConfigCookieEntryCollection configCookieEntrys;

        /// <summary>
        /// 
        /// </summary>
        [XmlElement("cookie")]
        public ConfigCookieEntryCollection ConfigCookieEntrys
        {
            get { return configCookieEntrys; }
            set { configCookieEntrys = value; }
        }

        public ConfigCookieEntry GetConfigCookieEntry(string cookieName)
        {
            return ConfigCookieEntrys[cookieName];
        }

        public List<ConfigCookieEntry> GetClientCookieEntrys()
        {
            List<ConfigCookieEntry> cookieListForClient = new List<ConfigCookieEntry>();
            foreach (ConfigCookieEntry cookie in ConfigCookieEntrys)
            {
                if (cookie.RenderInClient)
                {
                    cookieListForClient.Add(cookie);
                }
            }
            return cookieListForClient;
        }
    }
}
